package csdn.jihe.li01;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class Test02 {
    public static void main(String[] args) {
        Collection<String> collection=new ArrayList<>();
        //常用方法测试-----------------------
        collection.add("hello");
        //boolean contains(Object var1);//判断是否包含
        boolean flag1=collection.contains("hello");
        System.out.println(flag1);
        //----------------------------------------------------
        Collection collection2=new ArrayList<>();
        //addAll
        collection.addAll(collection2);
        //boolean containsAll(Collection<?> var2);
        boolean flag2=collection.addAll(collection2);

        //----------------------------------------------------------
        //toArray();
        Object[] obj=collection.toArray();
        System.out.println(obj);
        System.out.println(Arrays.toString(obj));
        //remove 移除
        collection.remove("!");//------无返回
        boolean flag3=collection.remove("1");//-----有返回,只判断，不删除

        boolean flag4=collection.removeAll(collection2);

        //clear();
        collection.clear();

        //equals
        boolean flag5=collection.equals(collection2);

        //hashCode()
        //为什么集合的hashCode有的是正数有的是负数？
        System.out.println(collection.hashCode());
        System.out.println(collection2.hashCode());

        }
    }

